package cn.stronglink.asset.module.assetmanage.cabinetgroup.service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.toolkit.IdWorker;

import cn.stronglink.asset.model.CabinetGroup;
import cn.stronglink.asset.module.assetmanage.cabinetgroup.mapper.CabinetGroupMapper;
import cn.stronglink.suite.core.util.WebUtil;

@Service
@Transactional(rollbackFor = Exception.class)
public class CabinetGroupService {

	@Autowired
	private CabinetGroupMapper cabinetGroupMapper;

	@Transactional(propagation=Propagation.NOT_SUPPORTED,readOnly=true)
	public Page<CabinetGroup> queryList(Page<CabinetGroup> page, Map<String, Object> params) {
		List<CabinetGroup> list = cabinetGroupMapper.queryList(page, params);
		page.setRecords(list);
		return page;
	}

	/***
	 * 新增ipAddress表
	 * @param repair
	 * @return
	 */
	public int create(CabinetGroup param) {
		param.setId(IdWorker.getId());
		param.setCreateBy(WebUtil.getCurrentUser());
		param.setCreateTime(new Date());
		int count = cabinetGroupMapper.insertCabinetGroup(param);
		return count;
	}

	/***
	 * 更新
	 * @param ipAddress
	 */
	public void edit(CabinetGroup cabinetGroup) {
		cabinetGroup.setUpdateTime(new Date());
		cabinetGroup.setUpdateBy(WebUtil.getCurrentUser());
		// 更新维修单
		cabinetGroupMapper.updateCabinetGroup(cabinetGroup);
	}

	/***
	 * 删除
	 * @param id
	 */
	public void remove(Long id) {
		cabinetGroupMapper.remove(id);
	}

	/***
	 * 获取机柜组信息
	 * @param id
	 */
	@Transactional(propagation=Propagation.NOT_SUPPORTED,readOnly=true)
	public CabinetGroup qryById(Long id) {
		return  cabinetGroupMapper.qryById(id);
	}

	@Transactional(propagation=Propagation.NOT_SUPPORTED,readOnly=true)
	public List<CabinetGroup> queryAllList() {
		List<CabinetGroup>  list = cabinetGroupMapper.queryAllList();
		return list;
	}

	
}
